package com.cetccst.securitysuite.exception;

import static com.cetccst.securitysuite.log.SSLogger.logger;

import android.os.Process;

import com.cetccst.securitysuite.log.SSLogger;

public class CrashHandler implements Thread.UncaughtExceptionHandler {

    private static String TAG = CrashHandler.class.getSimpleName();

    private static CrashHandler INSTANCE = new CrashHandler();

    private CrashHandler() {
    }

    public static CrashHandler getInstance() {
        return INSTANCE;
    }

    public void initialize() {
        Thread.setDefaultUncaughtExceptionHandler(this);
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        logger.error("Agent is crashed", ex);
        // kill self after record crash log
        Process.killProcess(Process.myPid());
    }
}
